package com.maxd.controller.app;
import com.maxd.adapter.IgnoreSecurity;
import com.maxd.error.Result;
import com.maxd.model.App;
import com.maxd.service.app.IAppService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@RestController
@Api(value="APP升级管理",tags={"APP升级管理"})
@RequestMapping(value = "/appinfo")
public class APPController {
    @Autowired
    private IAppService iAppService;

    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
    @ApiOperation("管理平台升级详情")
    @ResponseBody
    public Result getBanner(@PathVariable Integer id) {
        return iAppService.findOne(Long.valueOf(id));
    }

    @RequestMapping(value = "/save", method = RequestMethod.POST)
    @ApiOperation("管理平台添加升级信息")
    @ResponseBody
    public Result addBanner(@RequestBody App app) {
        return iAppService.saveBody(app);
    }

    @RequestMapping(value = "/delete/{id}", method = RequestMethod.GET)
    @ApiOperation("管理平台删除升级信息")
    public Result deleteBanner(@PathVariable int id) {
        return iAppService.delete(id);
    }

    @RequestMapping(value = "/", method = RequestMethod.GET)
    @IgnoreSecurity
    @ApiOperation("用户端和管理平台 （用户端每次取第一个）获取app升级列表")
    @ResponseBody
    public Result getBannerList() {
        return iAppService.findAll();
    }


}
